package com.ddstation.crm.institution.mapper;

import com.ddstation.common.district.entity.MaDistrictEntity;
import com.ddstation.crm.institution.entity.DtHealthManageInstitutionInvsExpandEntity;
import com.ddstation.home_page.model.*;
import com.ddstation.hzsc_invs.institution_details.model.InstitutionDetailsDoctorModel;
import org.apache.ibatis.annotations.Param;

import com.ddstation.crm.institution.entity.DtHealthManageInstitutionEntity;
import org.omg.PortableServer.LIFESPAN_POLICY_ID;
import org.springframework.context.annotation.Role;

import java.util.HashMap;
import java.util.List;

/**
 * dt_health_manage_institution 健康管理机构
 * @author zhangdifeng
 * @date 2017年7月11日
 */
public interface DtHealthManageInstitutionMapper {
	public DtHealthManageInstitutionEntity select(@Param("id") String id);
	public DtHealthManageInstitutionEntity selectByName(@Param("name") String name);
	public DtHealthManageInstitutionEntity selectByNameAndInstitution(@Param("name") String name,@Param("id") String id);
	public DtHealthManageInstitutionEntity selectByNameCertified(@Param("name") String name, @Param("institutionId") String institutionId);
	public List<DtHealthManageInstitutionEntity> selectList(@Param("name") String name);
	public List<DtHealthManageInstitutionEntity> selectListByProvince(@Param("province") Integer province);
	public int update(DtHealthManageInstitutionEntity institution);
	public int insert(DtHealthManageInstitutionEntity entity);
	public int insertSelective(DtHealthManageInstitutionEntity entity);
	public int selectMaxInstitutionId();
	public int selectCnt(@Param("id") String id);
	/**查询除自身以外，同名的机构的条数据*/
	public int selectSameNameCnt(DtHealthManageInstitutionEntity institution);
	public DtHealthManageInstitutionEntity getInvsSettingsByInstitutionId(@Param("id") String id);

	/**
	 * 获取医疗机构信息
	 * @param institutionId
	 * @return
	 */
	public DtHealthManageInstitutionEntity selectByInstitutionIdForInvs(@Param("id")String institutionId);

	public List<DailyStatisticsModel> statisticsByTypeFirst(@Param("id")String id, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//病例总数查询
	public Integer statisticsDailyCase(@Param("_p")HpCommonParModel _p);

	//病例总数查询 机构
	public int statisticsDailyCaseInstitution(@Param("_p")HpCommonParModel _p);

	//处方总数查询
	public DailyStatisticsModel statisticsDailyPres(@Param("id")String id, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//处方总数查询 机构
	public int statisticsDailyPresInstitution(@Param("institutionId")String institutionId, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	public DailyStatisticsModel statisticsDailyAction(@Param("id")String id, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	public AllPartModel statisticsAbnormalInstitution(@Param("id")String id,@Param("type")Integer type, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	public AllPartModel statisticsErrorHandle(@Param("id")String id, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	public List<NameValueModel> presDailyByType(@Param("id")String id, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	/**
	 * 处方违规类型分布
	 * @param _p
	 * @return
	 */
	public List<HashMap> getPrescriptionIllegalDistributionList(@Param("_p") HpCommonParModel _p);

	//机构统查 => 根据机构行业类型获取机构信息
	public List<MapModel> getInstitutionInfoByInstitutionType(@Param("id")String id, @Param("institutionType")Integer institutionType);

	//机构统查 => 机构数量
	public Integer statisticsInstitutionReviewQuantity(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("town")Integer town);
	public Integer statisticsInstitutionReviewTotal(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("town")Integer town);

	//机构统查 => 行业类型
	public List<NameValueModel> statisticsInstitutionReviewType();

	//机构统查 => 行业
	public List<HashMap> statisticsInstitutionReviewIndustry(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county);

	//机构统查 => 等级
	public List<HashMap> statisticsInstitutionReviewLevel(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county);

	//机构统查 => 经济性质
	public HashMap statisticsInstitutionReviewEconomic(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county);

	//机构统查 => 所有权性质
	public List<HashMap> statisticsInstitutionReviewOwnership(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("town")Integer town);

	//机构统查 => 街道分布
	public List<HashMap> statisticsInstitutionReviewDistrict(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county);

	//机构统查 => 轮播
	public List<HashMap<String,Object>> statisticsInstitutionReviewCarousel(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county);

	public List<NameValueModel> selectCaseCoverage(@Param("_p")HpCommonParModel _p);

	public List<NameValueModel> selectAccountCoverage(@Param("_p")HpCommonParModel _p);

	//处方违规数(按街道归类)
//	public List<NameValueModel> selectPrescriptionViolation(@Param("id")String id, @Param("businessType")Integer businessType, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);
    public List<NameValueModel> selectPrescriptionViolation(@Param("_p")HpCommonParModel _p, @Param("businessType")Integer businessType);

	//处方违规数 机构
	public int selectPrescriptionViolationInstitution(@Param("_p")HpCommonParModel _p);

	//台账类型累计(按台账类型归类)
	public HashMap selectAccountType(@Param("id")String id, @Param("checkSt")Integer checkSt, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//台账异常数量按类型统计 机构
	public HashMap selectAccountTypeInstitution(@Param("_p")HpCommonParModel _p);

	//诊疗行为监管 => 机构数
	public int countInstitution(@Param("id")String id, @Param("businessType")Integer businessType, @Param("checkSt")Integer checkSt, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//异常台账/处方数
	public int countPrescriptionDaily(@Param("id")String id, @Param("businessType")Integer businessType, @Param("checkSt")Integer checkSt, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo, @Param("appealSt")Integer appealSt);

	//诊疗行为监管 => 处方违规机构等级
	public List<NameValueModel> presViolateInstitutionByLevel(@Param("id")String id,@Param("businessType")Integer businessType, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//诊疗行为监管 => 处方违规机构行业性质
	public List<NameValueModel> presViolateInstitutionByType(@Param("id")String id,@Param("businessType")Integer businessType, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//诊疗行为监管 => 处方违规机构经济性质
	public HashMap presViolateInstitutionByAttr(@Param("id")String id,@Param("businessType")Integer businessType, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//诊疗行为监管 => 异常处方机构散点图
	public List<MapModel> presViolateInstitution(@Param("id")String id,@Param("businessType")Integer businessType,  @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//综合应用 => 社会监督 => 无扫码记录机构数
	public int countNoQrcodeScanningInstitution(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//综合应用 => 社会监督 => 公众评价数 < 3
	public int countFewPublicCommentsInstitution(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("count")Integer count, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//综合应用 => 社会监督 => 满意度饼图数据
	public HashMap statisticsInstitutionSatisfaction(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//社会监督 => 二维码监督 => 公示医疗机构数
	public int countPublicityInstitutions(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county);

	//社会监督 => 二维码监督 => 累计公众评价数
	public int countPublicEvaluations(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//社会监督 => 二维码监督 => 累计二维码查询数
	public int countQrcodeScanning(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//社会监督 => 二维码监督 => 机构公众评价排序
	public List<HashMap> statisticsInstitutionByEvaluations(@Param("province")Integer province, @Param("city")Integer city, @Param("county")Integer county, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo, @Param("order")String order, @Param("limit")Integer limit);

	//根据输入名称 搜索机构列表
	public List<HashMap> searchInstitutionsByName(@Param("_p")HpCommonParModel _p, @Param("name")String name, @Param("street")Integer street, @Param("industry")Integer industry,@Param("economic")String economic, @Param("level")Integer level, @Param("ownership")Integer ownership);

	//根据输入名称 获取搜索到机构总数量
	public Integer searchInstitutionsCountByName(@Param("_p")HpCommonParModel _p, @Param("name")String name, @Param("street")Integer street, @Param("industry")Integer industry,@Param("economic")String economic, @Param("level")Integer level, @Param("ownership")Integer ownership);

	//搜索区域信息
	public List<MaDistrictEntity> selectDisctrictInfo(@Param("id")Integer id, @Param("parentId")Integer parentId);

	//click 机构信息插入更新
	public int clickInstitutionInsertOrUpdate(@Param("list") List<DtHealthManageInstitutionEntity> list);

	//机构详细信息
	public DtHealthManageInstitutionEntity selectInstitutionInfoByInstitutionId(@Param("id") String id);

	//机构详细信息 => 医生、护士数量
	public HashMap getInstitutionRoleCount(@Param("_p")HpCommonParModel _p);

	//机构详细信息 => 公众满意度 评价数量统计
	public List<HashMap> getSatisfactionCounts(@Param("institutionId") String institutionId, @Param("type") int type, @Param("dtFrom")String dtFrom, @Param("dtTo")String dtTo);

	//台账、处方违规趋势
	public List<NameValueModel> getIllegalTrendList(@Param("_p")HpCommonParModel _p);

	//综合展示 => 地图显示点
	public List<HashMap> getDisplayMapInfo(@Param("_p")HpCommonParModel _p);

	//电子处方数量查询
	public Integer statisticsDailyPrescription(@Param("_p")HpCommonParModel _p);

	//电子处方数量查询 机构
	public Integer statisticsInstitutionDailyPrescription(@Param("_p")HpCommonParModel _p);

	//获取机构 医师、护士信息
	public List<InstitutionDetailsDoctorModel> getDoctorsInfo(@Param("_p")HpCommonParModel _p);

	//预警处置 政府监督 消毒灭菌 列表
	public List<HashMap> getWdAccountSupervisionList(@Param("_p")HpCommonParModel _p);

	//获取搜索结果结构数量
	public Integer getInstitutionCount(@Param("_p")HpCommonParModel _p);

	//预警处置 政府监督 处方违规 列表
	public List<HashMap> getWdPrescriptionSupervisionList(@Param("_p")HpCommonParModel _p);

	public int getWdPrescriptionSupervisionCount(@Param("_p")HpCommonParModel _p);
}
